package com.itshare.video.mapper;

import com.itshare.video.pojo.po.Sort;
import com.itshare.video.pojo.po.SortExample;
import java.util.List;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.ResultMap;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.SelectKey;
import org.apache.ibatis.annotations.Update;
import org.apache.ibatis.session.RowBounds;

public interface SortMapper {
    long countByExample(SortExample example);

    int deleteByExample(SortExample example);

    @Delete({
        "delete from t_sort",
        "where sort_id = #{sortId,jdbcType=INTEGER}"
    })
    int deleteByPrimaryKey(Integer sortId);

    @Insert({
        "insert into t_sort (REVISION, CREATED_BY, ",
        "CREATED_TIME, UPDATED_BY, ",
        "UPDATED_TIME, sort, ",
        "sort_name, delete_status)",
        "values (#{revision,jdbcType=INTEGER}, #{createdBy,jdbcType=VARCHAR}, ",
        "#{createdTime,jdbcType=TIMESTAMP}, #{updatedBy,jdbcType=VARCHAR}, ",
        "#{updatedTime,jdbcType=TIMESTAMP}, #{sort,jdbcType=INTEGER}, ",
        "#{sortName,jdbcType=VARCHAR}, #{deleteStatus,jdbcType=INTEGER})"
    })
    @SelectKey(statement="SELECT LAST_INSERT_ID()", keyProperty="sortId", before=false, resultType=Integer.class)
    int insert(Sort record);

    int insertSelective(Sort record);

    List<Sort> selectByExampleWithRowbounds(SortExample example, RowBounds rowBounds);

    List<Sort> selectByExample(SortExample example);

    @Select({
        "select",
        "sort_id, REVISION, CREATED_BY, CREATED_TIME, UPDATED_BY, UPDATED_TIME, sort, ",
        "sort_name, delete_status",
        "from t_sort",
        "where sort_id = #{sortId,jdbcType=INTEGER}"
    })
    @ResultMap("com.itshare.video.mapper.SortMapper.BaseResultMap")
    Sort selectByPrimaryKey(Integer sortId);

    int updateByExampleSelective(@Param("record") Sort record, @Param("example") SortExample example);

    int updateByExample(@Param("record") Sort record, @Param("example") SortExample example);

    int updateByPrimaryKeySelective(Sort record);

    @Update({
        "update t_sort",
        "set REVISION = #{revision,jdbcType=INTEGER},",
          "CREATED_BY = #{createdBy,jdbcType=VARCHAR},",
          "CREATED_TIME = #{createdTime,jdbcType=TIMESTAMP},",
          "UPDATED_BY = #{updatedBy,jdbcType=VARCHAR},",
          "UPDATED_TIME = #{updatedTime,jdbcType=TIMESTAMP},",
          "sort = #{sort,jdbcType=INTEGER},",
          "sort_name = #{sortName,jdbcType=VARCHAR},",
          "delete_status = #{deleteStatus,jdbcType=INTEGER}",
        "where sort_id = #{sortId,jdbcType=INTEGER}"
    })
    int updateByPrimaryKey(Sort record);
}